/////////////////////////////////////////////////////////////////////////////
// Name:        variantstream.h
// Purpose:     Helper class for using variants in streams
// Author:      Julian Smart
// Modified by: 
// Created:     2009-02-27
// RCS-ID:      
// Copyright:   (c) Julian Smart
// License:     New BSD License
/////////////////////////////////////////////////////////////////////////////

#ifndef _VARIANTSTREAM_H_
#define _VARIANTSTREAM_H_

/*
 * Forward declarations
 */

class wxInputStream;
class wxOutputStream;
class wxDataInputStream;
class wxDataOutputStream;

/*!
 * wxDataStreamHelper helps with reading and writing attributes.
 */

class wxDataStreamHelper
{
public:
    wxDataStreamHelper(wxOutputStream& stream, wxDataOutputStream& dataStream)
    {
        Init();

        m_outputStream = & stream;
        m_dataOutputStream = & dataStream;
    }
    wxDataStreamHelper(wxInputStream& stream, wxDataInputStream& dataStream)
    {
        Init();

        m_inputStream = & stream;
        m_dataInputStream = & dataStream;
    }

    bool Read(wxVariant& variant);

    bool Write(const wxVariant& value);
    bool Write(const wxString& value, const wxString& name);
    bool WriteIfNotEmpty(const wxString& value, const wxString& name);
    bool Write(double value, const wxString& name);
    bool Write(long value, const wxString& name);
    bool Write(int value, const wxString& name);
    bool Write(bool value, const wxString& name);
    bool WriteEnd();

    void Init();

    wxOutputStream* GetOutputStream() const { return m_outputStream; }
    wxDataOutputStream* GetDataOutputStream() const { return m_dataOutputStream; }

    wxInputStream* GetInputStream() const { return m_inputStream; }
    wxDataInputStream* GetDataInputStream() const { return m_dataInputStream; }

protected:
    wxOutputStream*     m_outputStream;
    wxDataOutputStream* m_dataOutputStream;

    wxInputStream*      m_inputStream;
    wxDataInputStream*  m_dataInputStream;
};

#endif
    // _VARIANTSTREAM_H_
